<?php

declare(strict_types=1);

namespace App\Entity;

use App\Models\DmallCoupon;

class DmallCouponEntity extends ABaseEntity
{
    public function __construct(DmallCoupon $model)
    {
        $this->model = $model;
    }

    /**
     * @return DmallCouponEntity
     */
    public static function findByCode(string $code)
    {
        $model = DmallCoupon::where('code', $code)->first();
        if ($model === null) {
            return null;
        }

        return new self($model);
    }

    /**
     * 用户ID
     *
     * @return int
     */
    public function getUserId()
    {
        return $this->model->user_id;
    }

    /**
     * 用户ID
     */
    public function setUserId(int $userId)
    {
        $this->model->user_id = $userId;
    }

    /**
     * 唯一标识码
     *
     * @return string
     */
    public function getCode()
    {
        return $this->model->code;
    }

    /**
     * 唯一标识码
     */
    public function setCode(string $code)
    {
        $this->model->code = $code;
    }

    public function getStatus(): int
    {
        return $this->model->status;
    }

    public function setStatus(int $status): void
    {
        $this->model->status = $status;
    }

    /**
     * 用户ID
     */
    public function setActivityId(int $activityId)
    {
        $this->model->activity_id = $activityId;
    }

    public function getActivityId(): int
    {
        return $this->model->activity_id;
    }
}
